import request from '@/utils/request.js'

export const varietyListService = ()=>{
    //在pinia中定义的响应式数据可以直接使用
    return request.get('/variety/list')
}
export const categoryListService = (id)=>{
    return request.get('/variety/subList?id='+id)
}

//add
export const varietyAddService = (varietyData)=> {
    return request.post('/variety/subAdd?variety='+varietyData.variety+'&category='+varietyData.category+'&pic='+varietyData.pic)
}

//update
export const varietyUpdateService = (current,varietyData)=> {
    if(current === 'variety'){
        return request.put('/variety/update',varietyData)
    }else{
        return request.patch('/variety/subUpdate?variety='+varietyData.variety+'&category='+varietyData.category+'&id='+varietyData.id+'&pic='+varietyData.pic)
    }
}

//delete
export const varietyDeleteService = (current,id)=> {
    if(current.value === 'variety'){
        return request.delete('/variety/delete?id='+id)
    }else{
        return request.delete('/variety/subDelete?id='+id)
    }
}